<link rel="stylesheet" href="__STATIC_LIB__layuiadmin/layui/layui_ext/dtree/dtree.css">
<link rel="stylesheet" href="__STATIC_LIB__layuiadmin/layui/layui_ext/dtree/font/dtreefont.css">

<div style="padding: 30px;" class="layui-form layui-form-pane">

    <input type="hidden" name="id" value="{$data.id}">

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i>上级部门：</label>
        <div class="layui-input-inline" style = "width: 260px">
            <input type="text" name="pid" value = "{$data.pid}" autocomplete="off" class="layui-input layui-hide">
            <tree id="deptTreeAdd" class="dtree" data-id="0"  ></tree>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i> 部门编号：</label>
        <div class="layui-input-inline seller-inline-4">
            <input type="text" name="id" style="width: 260px;" required lay-verify="required" disabled ="true" placeholder="请输入部门编号" autocomplete="off" class="layui-input" value="{$data.id}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i> 部门名称：</label>
        <div class="layui-input-inline seller-inline-4">
            <input type="text" name="name" style="width: 260px;" required lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input" value="{$data.name}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i>排序：</label>
        <div class="layui-input-inline seller-inline-4">
            <input type="text" name="sort" style="width: 260px;" required lay-verify="required" placeholder="数值越小越靠前" autocomplete="off" class="layui-input" value="{$data.sort}">
        </div>
    </div>
    {:zlserverToken()}
    <button id="dept_edit_save" class="layui-btn layui-btn-fluid" lay-submit lay-filter="dept-Edit">保存</button>

</div>

<script>
    layui.extend({
        dtree: '__STATIC_LIB__layuiadmin/layui/layui_ext/dtree/dtree'
    }).use(['form', 'laydate', 'dtree'], function () { 
        var form = layui.form, laydate = layui.laydate, dtree = layui.dtree;
        form.render();

        var deptTree = dtree.renderSelect({
            elem: "#deptTreeAdd",
            url: '{:url("Dept/getList")}',
            selectTips: "请选择部门",
            menubar: true, //开启菜单栏
            checkbar: false,
            width: "100%", // 指定树的宽度
            selectCardHeight: "180",
            response:{message:"msg",statusCode:0},
            dataStyle: "layuiStyle",
            done: function(res, $ul, first){
                dtree.selectVal("deptTreeAdd", "{$data.pid}"); 
            }
        });
    });
</script>